<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Giaodich_model extends CI_Model {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->database();  
    }
    public function load_chongiasu($id,$id_giasu) {
        $data = array(
            'Lamgiasu_id' => $id_giasu,
            'thanhvien_id'=>$id,
            'TrangThai'=>false,
        );
        $this->db->select('Lamgiasu_id','thanhvien_id');
        $this->db->from('gs7s_lamgiasu_cho');
        $this->db->where('Lamgiasu_id',$id_giasu);
        $this->db->where('thanhvien_id',$id);
        $this->db->limit(1);
        $query = $this->db->get();
        if ($query->num_rows !=1)
        {
            $this->db->insert('gs7s_lamgiasu_cho',$data);
        }
    }
    public function load_chonlop($id,$id_lop) {
        $data = array(
            'TimGiaSu_Id' => $id_lop,
            'thanhvien_id'=>$id,
            'TrangThai'=>false,
        );
        $this->db->select('TimGiaSu_Id','thanhvien_id');
        $this->db->from('gs7s_timgiasu_cho');
        $this->db->where('TimGiaSu_Id',$id_lop);
        $this->db->where('thanhvien_id',$id);
        $this->db->limit(1);
        $query = $this->db->get();
        if ($query->num_rows !=1)
        {
            $this->db->insert('gs7s_timgiasu_cho',$data);
        }
    }
     public function load_hoanthanh_chongiasu($id_timgiasu) {
         $data['TimGiaSu_TrangThai_id']=2;
         $this->db->where('id',$id_timgiasu);
         $this->db->update('gs7s_timgiasu',$data);
    }
    public function load_hoanthanh_chonlop($id_lamgiasu) {
         $data['LamGiaSu_TrangThai_id']=2;
         $this->db->where('id',$id_lamgiasu);
         $this->db->update('gs7s_lamgiasu',$data);
    }
    public function taolop($timgiasu,$id_phuhuynh,$id_giasu){
        //insert lophoc_thongtin
        $a['SoLuongHocSinh']='1';
        $data = array(
            'TrangThaiLopHoc_Id'=>1,
            'Id_GiaSu'=>$id_giasu,
            'Id_PhuHuynh'=>$id_phuhuynh,
        );
        $this->db->insert('gs7s_lophoc',$data);
    }
 }
?>
